/**
 * @Title: integrityArtificialScoreDissMiss_ctrl.js
 * @Description: TODO
 * Copyright: Copyright (c) 2015
 * Company:中国平安
 *
 * @Project mhis_web
 * @author EX-LILIUZHU001
 * @date 2015年2月9日 下午5:55:20
 * @version V1.0
 */
;
(function(){
	'use strict';	
	var app = angular.module('fwa.mainApp');
	app.controller('IntegrityArtificialScoreDetailCtrl', ['$scope','$http','$modalInstance','$stateParams','BaseURL','Modal','FwaTabsetService','IntegrityMedicalService','CommunityService','WarningScreenService','IntegrityArtificialScoreService','$modal',
	                              function($scope,$http,$modalInstance,$stateParams,baseUrl,Modal,FwaTabsetService,IntegrityMedicalService,CommunityService,WarningScreenService,IntegrityArtificialScoreService,$modal){
		var params = function(){
			var startDate = "";
			if(IntegrityMedicalService.startDate&&!angular.isUndefined(IntegrityMedicalService.startDate)){
				startDate = IntegrityMedicalService.startDate;
			}
			var endDate="";
			if(IntegrityMedicalService.endDate&&!angular.isUndefined(IntegrityMedicalService.endDate)){
				endDate = IntegrityMedicalService.endDate;
			}
			var taskNo="";
			if(IntegrityMedicalService.taskNo&&!angular.isUndefined(IntegrityMedicalService.taskNo)){
				taskNo = IntegrityMedicalService.taskNo;
			}
			var params = {
					startDate:startDate,
					endDate:endDate,
					taskNo:taskNo
			}
			return params;
		};
		IntegrityMedicalService.getIntegrityAuditDetail(params()).
		success(function(res){
			$scope.doctorName = IntegrityMedicalService.doctorName;
			$scope.startDate = IntegrityMedicalService.startDate;
			$scope.endDate = IntegrityMedicalService.endDate;
			$scope.auditInfo = res;
		});
		//获取总分
		   WarningScreenService.getPointScose({targetNo:IntegrityMedicalService.doctorCode}).
			success(function(res){
				if(res.pointScose){
					$scope.orgContentPoint = res.pointScose;//考核内容已记分值
					$scope.deductionScores = parseFloat(res.pointScose).toFixed(1);
				}else{
					$scope.orgContentPoint = null;
				}
			});
		   
			//关闭
			$scope.onClose = function(){
	    		$modalInstance.dismiss();
	    	}
			$scope.audit = function(){
				var params = {
						taskNo:IntegrityMedicalService.taskNo,
						status:IntegrityMedicalService.status
				};
                Modal.confirm('确认撤销吗？',function() {
                	$scope.form.loading=true;
                	IntegrityArtificialScoreService.backIntegrityDoctorProcess(params).success(function(res){                		
                		if (res.state == '0') {
                			Modal.alert(res.msg);
                			$scope.form.loading=false;
                			$modalInstance.close(true);
                		}else{
                			Modal.alert("撤销失败！");
                			$scope.form.loading=false;
                		}
                	});
                   /* $http.post(baseUrl + 'doctorIntegrity/auditConfirm.do', params).success(function (data) {
                        if (data.state = '0') {
                            Modal.alert("审核通过！");
                            $modalInstance.close(true);
                        } else {
                            Modal.alert("审核失败！");
                        }
                    })*/
                })
			}
}]);
})();